package com.jingyanzi.sys.impl;

import java.util.ArrayList;
import java.util.List;

import com.jingyanzi.sys.domain.AddressDO;
import com.jingyanzi.sys.domain.DictionariesDO;
import com.jingyanzi.sys.domain.MemberGradeDO;
import com.jingyanzi.sys.domain.NameMappingDO;
import com.jingyanzi.sys.domain.NoticeDO;
import com.jingyanzi.sys.domain.OperateLogsDO;
import com.jingyanzi.sys.domain.RightsDO;
import com.jingyanzi.sys.domain.SettingDO;
import com.jingyanzi.sys.entity.SysAddress;
import com.jingyanzi.sys.entity.SysDictionaries;
import com.jingyanzi.sys.entity.SysMemberGrade;
import com.jingyanzi.sys.entity.SysNameMapping;
import com.jingyanzi.sys.entity.SysNotice;
import com.jingyanzi.sys.entity.SysOperateLogs;
import com.jingyanzi.sys.entity.SysRights;
import com.jingyanzi.sys.entity.SysSetting;
import com.jingyanzi.sys.util.BeanUtilsExtends;

/**
 * @author reagan
 * @Description:基础服务类主要用来实现底层的通用方法
 */
public class BaseServiceImpl {
	
	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param obj
	 * @return 返回DO对象
	 */
	public NoticeDO getNoticeDO(SysNotice obj) {
		if (obj == null)
			return null;
		NoticeDO dst = new NoticeDO();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<NoticeDO> getNoticeDOList(List<SysNotice> list) {
		List<NoticeDO> result = new ArrayList<NoticeDO>();
		if (list != null && !list.isEmpty()) {
			for (SysNotice org : list) {
				NoticeDO org1 = new NoticeDO();
				BeanUtilsExtends.copy(org1, org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}
	
	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param obj
	 * @return 返回DO对象
	 */
	public SettingDO getSettingDO(SysSetting obj) {
		if (obj == null)
			return null;
		SettingDO dst = new SettingDO();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<SettingDO> getSettingDOList(List<SysSetting> list) {
		List<SettingDO> result = new ArrayList<SettingDO>();
		if (list != null && !list.isEmpty()) {
			for (SysSetting org : list) {
				SettingDO org1 = new SettingDO();
				BeanUtilsExtends.copy(org1, org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}
	
	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param obj
	 * @return 返回DO对象
	 */
	public NameMappingDO getNameMappingDO(SysNameMapping obj) {
		if (obj == null)
			return null;
		NameMappingDO dst = new NameMappingDO();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<NameMappingDO> getNameMappingDOList(List<SysNameMapping> list) {
		List<NameMappingDO> result = new ArrayList<NameMappingDO>();
		if (list != null && !list.isEmpty()) {
			for (SysNameMapping org : list) {
				NameMappingDO org1 = new NameMappingDO();
				BeanUtilsExtends.copy(org1, org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}

	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param obj
	 * @return 返回DO对象
	 */
	public DictionariesDO getDictionariesDO(SysDictionaries obj) {
		if (obj == null)
			return null;
		DictionariesDO dst = new DictionariesDO();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<DictionariesDO> getDictionariesDOList(List<SysDictionaries> list) {
		List<DictionariesDO> result = new ArrayList<DictionariesDO>();
		if (list != null && !list.isEmpty()) {
			for (SysDictionaries org : list) {
				DictionariesDO org1 = new DictionariesDO();
				BeanUtilsExtends.copy(org1, org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}

	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param obj
	 * @return 返回DO对象
	 */
	public OperateLogsDO getOperateLogsDO(SysOperateLogs obj) {
		if (obj == null)
			return null;
		OperateLogsDO dst = new OperateLogsDO();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<OperateLogsDO> getOperateLogsDOList(List<SysOperateLogs> list) {
		List<OperateLogsDO> result = new ArrayList<OperateLogsDO>();
		if (list != null && !list.isEmpty()) {
			for (SysOperateLogs org : list) {
				OperateLogsDO org1 = new OperateLogsDO();
				BeanUtilsExtends.copy(org1, org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}
	
	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param obj
	 * @return 返回DO对象
	 */
	public AddressDO getOperateLogsDO(SysAddress obj) {
		if (obj == null)
			return null;
		AddressDO dst = new AddressDO();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<AddressDO> getAddressDOList(List<SysAddress> list) {
		List<AddressDO> result = new ArrayList<AddressDO>();
		if (list != null && !list.isEmpty()) {
			for (SysAddress org : list) {
				AddressDO org1 = new AddressDO();
				BeanUtilsExtends.copy(org1, org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}
	
	
	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param obj
	 * @return 返回DO对象
	 */
	public RightsDO getRightsDO(SysRights obj) {
		if (obj == null)
			return null;
		RightsDO dst = new RightsDO();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<RightsDO> getRightsDOList(List<SysRights> list) {
		List<RightsDO> result = new ArrayList<RightsDO>();
		if (list != null && !list.isEmpty()) {
			for (SysRights org : list) {
				RightsDO org1 = new RightsDO();
				BeanUtilsExtends.copy(org1, org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}
	

	/**
	 * 对象拷贝单个实体到对象中
	 * 
	 * @param obj
	 * @return 返回DO对象
	 */
	public MemberGradeDO getMemberGradeDO(SysMemberGrade obj) {
		if (obj == null)
			return null;
		MemberGradeDO dst = new MemberGradeDO();
		return BeanUtilsExtends.copyProperties(dst, obj) ? dst : null;
	}

	/**
	 * 对象拷贝多个实体到列表中
	 * 
	 * @param List
	 * @return List
	 */
	public List<MemberGradeDO> getMemberGradeDOList(List<SysMemberGrade> list) {
		List<MemberGradeDO> result = new ArrayList<MemberGradeDO>();
		if (list != null && !list.isEmpty()) {
			for (SysMemberGrade org : list) {
				MemberGradeDO org1 = new MemberGradeDO();
				BeanUtilsExtends.copy(org1, org);
				if (org1 != null) {
					result.add(org1);
				}
			}
		}
		return result;
	}

	/**
	 * 判断整型数据是否无效： null或<1为无效,返回true; >=1为有效，返回false
	 */
	public static boolean isNumberInValid(Integer value) {
		if (value == null) {
			return true;
		} else if (value < 1) {
			return true;
		}
		return false;
	}
}
